# -*- coding: utf-8 -*-
# @Author: slp
# @Date:   2017-07-07 08:44:58
# @Last Modified by:   slp
# @Last Modified time: 2017-07-14 16:48:19

def show_bin(num, sl=None):
	sn = hex(num)
	b = bin(num)
	l = len(b)
	h = ""
	bn = ""
	hn = ""
	for i in xrange(len(b), 2, -8):
		h = "%-3d-%4d "%(l-i+7, l-i) + h
		bn = "%8s "%(b[(i>10 and i-8 or 2) :i]) + bn
		j = i/4
		hn = "%8s "%(sn[(j>2 and j or 2):j+2]) + hn

	if sl != None and sl > l-2:
		for i in xrange(sl, (l-3) / 8 * 8 + 8, -8):
			h = "%-3d-%4d "%(i-1, i-8) + h
			bn = "%8s "%(" ") + bn
			hn = "%8s "%(" ") + hn
	print h
	print bn
	print hn

num = 0x30c51815
show_bin(num, 32)

show_bin(0x00c00811, 32)

show_bin(0xcfdfdfdfdfdfdfcf)


print 0x28
print hex(48)


show_bin(0x80000060)

show_bin(0x81800000)

show_bin(int("10000001100000001000000000100000", 2))

show_bin(0x80000050)

show_bin(0x8000004c)
show_bin(0x9000000390000003)

show_bin(0x80000054)